/*
 * @Description: 你的代码我的心
 * @Author: GGB
 * @Date: 2021-12-22 14:10:13
 * @LastEditors: GGB
 * @LastEditTime: 2022-01-11 09:36:52
 */
import {
  GoodsPageParms,
  GoodsListGetResultModel,
  UpdateState,
  UpdateStockParam,
  GoodsParams,
} from './model/goodsModel';
import { defHttp } from '/@/utils/http/axios';

import { BasicResult } from '../model/baseModel';

enum Api {
  GoodsList = '/goods/list',
  GoodsListByIds = '/goods/listByIds',
  GoodsDetail = '/goods/detail',
  AddGoods = '/goods/add',
  EditGoods = '/goods/edit',
  DeleteGoods = '/goods/delete',
  GoodsState = '/goods/state',
  SaveSku = '/goods/saveSku',
}
/**
 * 获取商品列表
 */
export const getGoodsList = (params: GoodsPageParms) =>
  defHttp.get<GoodsListGetResultModel>({ url: Api.GoodsList, params });

/**
 * 更新商品状态
 * @param params
 * @returns
 */
export const updateGoodState = (params: UpdateState) =>
  defHttp.post<BasicResult>({ url: Api.GoodsState, params });

/**
 * 获取商品详情
 * @param params
 * @returns
 */
export const getGoodDetail = (params: GoodsParams) =>
  defHttp.get<BasicResult>({ url: Api.GoodsDetail, params });

/**
 * 更新商品状态
 * @param params
 * @returns
 */
export const updateGoodsStock = (params: UpdateStockParam) =>
  defHttp.post<BasicResult>({ url: Api.SaveSku, params });
